package org.easystub;

public class InvocationHandlerParameters<T> {

    private final InvocationReporter reporter;
    private final InvocationAnswerer defaultAnswerer;
    private final RecordedInvocationAnswerer recordedAnswerer;
    private final CaptureStore captureStore;
    private final Class<T> stubbedClass;

    public InvocationHandlerParameters(Class<T> stubbedClass, ReplyType replyBehaviourType) {
        recordedAnswerer = new RecordedInvocationAnswerer();
        reporter = new InvocationReporter();
        captureStore = new CaptureStore();
        this.stubbedClass = stubbedClass;
        defaultAnswerer = buildDefaultAnswerer(replyBehaviourType);
    }

    private InvocationAnswerer buildDefaultAnswerer(ReplyType replyBehaviourType) {
        switch (replyBehaviourType) {
            case DEFAULT_VALUES:   return new DefaultInvocationAnswerer();
            case THROW_EXCEPTIONS: return new DefaultExceptionInvocationAnswerer();
            default: throw new IllegalArgumentException("unsupported default reply behaviour");
        }
    }

    public InvocationReporter getReporter() {
        return reporter;
    }

    public InvocationAnswerer getDefaultAnswerer() {
        return defaultAnswerer;
    }

    public RecordedInvocationAnswerer getRecordedAnswerer() {
        return recordedAnswerer;
    }

    public CaptureStore getCaptureStore() {
        return captureStore;
    }

    public Class<T> getStubbedClass() {
        return stubbedClass;
    }
}
